<template>
  <div class="container">
    <el-form
      label-width="80px"
      :rules="rules"
      :model="data"
      ref="specialCargoForm"
      :show-message="false"
    >
      <div class="middle-box special no-border-top">
        <span class="title"> 冷藏品 </span>
      </div>
      <div class="message-input-container">
        <el-row :gutter="24">
          <el-col :span="6">
            <!-- prop="coldTemp" -->
            <el-form-item label="冷藏温度">
              <div class="responsiveLayout">
                <el-input
                  v-model="data.coldTemp"
                  style="width: 70%"
                  placeholder="请输入"
                  clearable
                ></el-input>
                <el-select
                  v-model="data.coldTempUnit"
                  style="width: 30%; margin-left: 8px"
                  size="small"
                  filterable
                  placeholder="单位"
                >
                  <el-option value="C" label="C"> </el-option>
                  <el-option value="F" label="F"> </el-option>
                </el-select>
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <!-- prop="ventilationRate" -->
            <el-form-item label="通风量">
              <div class="responsiveLayout">
                <el-input
                  v-model="data.ventilationRate"
                  style="width: 70%"
                  placeholder="请输入"
                  clearable
                ></el-input>
                <el-select
                  style="width: 30%; margin-left: 8px"
                  v-model="data.ventilationRateUnit"
                  size="small"
                  filterable
                  placeholder="单位"
                >
                  <el-option
                    v-for="(item, index) in options"
                    :key="index"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div class="middle-box">
        <span class="title"> 危险品 </span>
      </div>
      <div class="message-input-container">
        <el-row :gutter="24">
          <el-col :span="6">
            <!-- prop="unno" -->
            <el-form-item label="UN NO">
              <el-input
                v-model="data.unno"
                placeholder="请输入"
                clearable
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <!-- prop="type" -->
            <el-form-item label="CLASS NO">
              <el-input
                v-model="data.type"
                placeholder="请输入"
                clearable
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <!-- prop="flashTemp" -->
            <el-form-item label="闪点">
              <div class="responsiveLayout">
                <el-input
                  v-model="data.flashTemp"
                  style="width: 70%"
                  placeholder="请输入"
                  clearable
                ></el-input>
                <el-select
                  v-model="data.flashTempUnit"
                  size="small"
                  filterable
                  placeholder="单位"
                  style="width: 30%; margin-left: 8px"
                >
                  <el-option value="C"> </el-option>
                  <el-option value="F"> </el-option>
                </el-select>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
      </div>

      <div class="middle-box">
        <span class="title"> OOG </span>
      </div>
      <div class="message-input-container">
        <el-row :gutter="24">
          <el-col :span="6">
            <!-- prop="cargoUnit" -->
            <el-form-item label="尺寸单位">
              <!-- <docSelects
                v-model:modelData="data.size"
                placeholder="请选择"
                :option="$store.state.businessBaseData.dictData['sys_bl_type']"
              >
              </docSelects> -->
              <el-input
                v-model="data.cargoUnit"
                placeholder="请输入"
                clearable
                filterable
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <!-- prop="overFrontLength" -->
            <el-form-item label="超限-前">
              <el-input
                v-model="data.overFrontLength"
                placeholder="请输入"
                clearable
                filterable
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <!-- prop="overBackLength" -->
            <el-form-item label="超限-后">
              <el-input
                v-model="data.overBackLength"
                placeholder="请输入"
                clearable
                filterable
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <!-- prop="overLeftLength" -->
            <el-form-item label="超限-左">
              <el-input
                v-model="data.overLeftLength"
                placeholder="请输入"
                clearable
                filterable
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="6">
            <!-- prop="overRightLength" -->
            <el-form-item label="超限-右">
              <el-input
                v-model="data.overRightLength"
                placeholder="请输入"
                clearable
                filterable
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <!-- prop="overHeightLength" -->
            <el-form-item label="超限-高">
              <el-input
                v-model="data.overHeightLength"
                placeholder="请输入"
                clearable
                filterable
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
    </el-form>
  </div>
</template>

<script>
import { defineComponent } from 'vue'
// import selectDown from './../components/selectDown.vue'
import selectDown from './selectDownNew.vue'
import docSelects from './../components/docSelects.vue'
export default defineComponent({
  components: {
    selectDown,
    docSelects
  },
  props: {
    //详细数据
    detailData: {
      type: Object,
      default: () => {}
    },
    //初始化option
    initOption: {
      type: Object,
      default: () => {}
    }
  },
  emits: ['update:detailData'],
  computed: {
    data: {
      get() {
        return this.detailData
      },
      set(value) {
        this.$emit('update:detailData', value)
      }
    }
  },
  data() {
    return {
      formData: {},
      inkey: 0,
      radio1: '1',
      useXiangData: [
        {
          id: 1,
          xiangxin: '',
          xiangliang: 1,
          useXiangXuQiu: 'SOC',
          hasDeleteIcon: false //是否有删除图标
        }
      ],
      num: 1,
      options: [
        {
          value: '开',
          label: '开'
        },
        {
          value: '关',
          label: '关'
        },
        {
          value: '半开',
          label: '半开'
        },
        {
          value: 10,
          label: '10'
        },
        {
          value: 20,
          label: '20'
        },
        {
          value: 30,
          label: '30'
        },
        {
          value: 40,
          label: '40'
        },
        {
          value: 50,
          label: '50'
        },
        {
          value: 60,
          label: '60'
        },
        {
          value: 70,
          label: '70'
        },
        {
          value: 80,
          label: '80'
        }
      ],
      rules: {
        coldTemp: [
          {
            required: true,
            validator: this.validatorTemperature,
            trigger: ['blur', 'change']
          }
        ],
        unno: [{ required: true, message: '请输入UN NO', trigger: 'blur' }],
        type: [{ required: true, message: '请输入CLASS NO', trigger: 'blur' }],
        flashTemp: [
          {
            required: true,
            validator: this.validatorDangerFlashPoint,
            trigger: ['blur', 'change']
          }
        ],
        overFrontLength: [
          { required: true, message: '请输入超限-前', trigger: 'blur' }
        ],
        overBackLength: [
          { required: true, message: '请输入超限-后', trigger: 'blur' }
        ],
        overLeftLength: [
          { required: true, message: '请输入超限-左', trigger: 'blur' }
        ],
        overRightLength: [
          { required: true, message: '请输入超限-右', trigger: 'blur' }
        ],
        overHeightLength: [
          { required: true, message: '请输入超限-高', trigger: 'blur' }
        ],
        cargoUnit: [
          { required: true, message: '请选择尺寸单位', trigger: 'change' }
        ],
        ventilationRate: [
          {
            required: true,
            validator: this.validatorVentilationQuantity,
            trigger: ['blur', 'change']
          }
        ]
      }
    }
  },
  methods: {
    // 校验闪点
    validatorDangerFlashPoint(rule, value, callback) {
      let allFieldsFilled = true
      if (!this.data.flashTemp || !this.data.flashTempUnit) {
        allFieldsFilled = false
      }
      if (!allFieldsFilled) {
        callback(new Error('闪点和单位不能为空'))
      } else {
        callback()
      }
    },
    // 校验冷藏温度
    validatorTemperature(rule, value, callback) {
      let allFieldsFilled = true
      if (!this.data.coldTemp || !this.data.coldTempUnit) {
        allFieldsFilled = false
      }
      if (!allFieldsFilled) {
        callback(new Error('冷藏的温度和单位不能为空'))
      } else {
        callback()
      }
    },
    // 校验通风量
    validatorVentilationQuantity(rule, value, callback) {
      let allFieldsFilled = true
      if (!this.data.ventilationRate || !this.data.ventilationRateUnit) {
        allFieldsFilled = false
      }
      if (!allFieldsFilled) {
        callback(new Error('通风量和单位不能为空'))
      } else {
        callback()
      }
    }
  },
  mounted() {},
  created() {}
})
</script>

<style lang="scss" scoped>
@import '@/styles/business/business.scss';
.el-textarea__inner {
  line-height: 1.2 !important;
}

.container {
  :deep(.el-form-item) {
    margin: 0;
  }

  :deep(.el-row) {
    margin-bottom: 8px;
    // padding-right: 16px;
  }

  .middle-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
  }

  .table-header::before {
    content: '*';
    color: #ff0000;
    font-family: PingFang SC;
    font-weight: 400;
    font-size: 12px;
    letter-spacing: 0px;
  }

  ::v-deep .el-checkbox {
    margin-right: 10px;
  }

  ::v-deep .el-checkbox__label {
    font-size: 12px;
  }

  .responsiveLayout {
    width: 100%;
    display: flex;
  }

  ::v-deep .el-input-number__decrease {
    background-color: #fff;
    border-right: none;
  }
  ::v-deep .el-input-number__increase {
    background-color: #fff;
    border-left: none;
  }

  .addUseBoxInfo {
    color: #6ba5f6;
    cursor: pointer;
    width: 50px;
    height: 21px;
    display: flex;
    align-items: center;
    margin: 12px 0 10px 8px;
    .addFont {
      margin-left: 3px;
      line-height: 21px;
    }
  }

  .flex-column {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    text-align: right;

    .sencond-title {
      color: #000000;
      opacity: 0.4;
      font-family: PingFang SC;
      font-weight: 400;
      font-size: 12px;
      letter-spacing: 0px;
    }
  }
}
</style>
